import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { SingerDetail } from '../entity';
import { SingerService } from 'src/app/shared';

@Injectable()
export class SingerDetailResolve implements Resolve<SingerDetail> {

  constructor(
   private singerService: SingerService
  ) { }

  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<SingerDetail> {
    const id = route.paramMap.get('id');
    return this.singerService.getSingerDetail(id);
  }

}
